﻿#ifndef __AVOID_CONTROL_EDIT_CARET_HEAD_FILE_INCLUDED__
#define __AVOID_CONTROL_EDIT_CARET_HEAD_FILE_INCLUDED__
#include "../ctlDefine.h"
#include <Windows.h>

namespace swui
{
	class ctlRoot;
	namespace _ctlInterior
	{
		// 插入符
		class caret
		{
		public:
			caret();
			void enable(bool e);
			void setPos(ctlPoint position);
			void setLevel(ctlRoot* r) 
			{
				setStatus(true);
				level = r; 
			}
			void setLength(int len) { length = len; }
			void setStatus(bool s) { displayStatus = s; }
			void bindExit(HANDLE hExit, HWND hWnd);
			void waitExit();
			int getLength() { return length; }
			ctlPoint getPos() { return position; }
			bool display() { return displayStatus; }
			ctlRoot* getLevel() { return level; }
			void setColor(ctlColor c);
			HPEN getObject() { return hPen; }
			bool isEnabled() { return enabled; }
		private:
			static DWORD CALLBACK caretFlusher(LPVOID obj);
			ctlPoint position;
			bool enabled;
			unsigned flushTime;
			bool displayStatus;
			int length;
			HWND hWnd;
			ctlRoot* level;
			HANDLE flushThread, hExitEvent;
			HPEN hPen;
		};
	}
}

#endif